{extend name='extra@admin/content'}
{block name="button"}
<div class="nowrap pull-right" style="margin-top:10px">
{if auth("/index.php/mall/export/apply_material")}
    <a href='javascript:;' class='layui-btn layui-btn-small' style="text-decoration:none" onclick="daochu();">导出</a>
{/if}
</div>
{/block}
{block name="content"}
<!-- 表单搜索 开始 -->
<form class="animated form-search" action="__SELF__" onsubmit="return false" method="get">
    <div class="row">
        <div class="col-xs-2">
            <div class="form-group">
                <select name="material_id" id="material_id" class="input-sm form-control">
                    <option value="">- 选择原材料 -</option>
                    {foreach $goods as $v1}
                    <option value="{$v1.id}" {if $Think.get.material_id eq $v1['id']} selected {/if}>- {$v1.name} -</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="col-xs-1">
            <div class="form-group">
                <button type="submit" class="btn btn-sm btn-white"><i class="fa fa-search"></i> 搜索</button>
            </div>
        </div>
    </div>
</form>
<!-- 表单搜索 结束 -->

<form onsubmit="return false;" data-auto="true" method="post">
    {if empty($list)}
    <p class="help-block text-center well">没 有 记 录 哦！</p>
    {else}
    <input type="hidden" value="resort" name="action"/>
    <table class="layui-table" lay-skin="line" lay-size="sm">
        <thead>
            <tr>
               <!--  <th class='list-table-check-td'>
                    <input data-none-auto="" data-check-target='.list-check-box' type='checkbox'/>
                </th> -->
                <th class='text-left nowrap'>商品名称</th>
                <th class='text-left nowrap'>类型</th>
                <th class='text-left nowrap'>变更数</th>
                <th class='text-left nowrap'>当前库存</th>
                <th class='text-left nowrap'>添加时间</th>
            </tr>
        </thead>
        <tbody>
            {foreach $list as $key=>$vo}
            <tr>
                <!-- <td class='list-table-check-td'>
                    <input class="list-check-box" value='{$vo.id}' type='checkbox'/>
                </td> -->
                <td class='text-left nowrap'>
                    {$vo.name}
                </td>
                <td class='text-left nowrap'>
                    {if condition="$vo['sign'] eq 1"}进货
                    {elseif condition="$vo['sign'] eq 2" /}提货
                    {else /}报损
                    {/if}
                </td>
                <td class='text-left nowrap'>
                    {if condition="$vo['type'] eq 1"}+{else /}-{/if}{$vo.res_num}
                </td>
                <td class='text-left nowrap'>
                    {$vo.cur_num}
                </td>
                <td class='text-left nowrap'>
                    {$vo.addtime|date="Y-m-d",###}
                </td>
            </tr>
            {/foreach}
        </tbody>
    </table>
    {if isset($page)}<p>{$page}</p>{/if}
    {/if}
    <script>
        window.laydate.render({range: true, elem: '#range-date', format: 'yyyy/MM/dd'});
        function daochu(){
            var material_id = $('#material_id option:selected').val();       //搜索条件
            if(material_id > 0){
                window.location='{:url("$classuri/chengpin_stock_log")}?export=1&material_id='+material_id;
            }else{
                window.location='{:url("$classuri/chengpin_stock_log")}?export=1';
            }
        }
    </script>
</form>
{/block}